$(function(){
// 表单验证
$("#commentForm").validate({
    messages: {
    	 linkPerson: {
            required: "请输入联系人",
            minlength: "联系人必需由两个字符组成"
        },
       linkWay:{
            required: "请输入手机号或邮箱",
            minlength: "数字，字母或符号"
        },
        content:{
            required: "请输入留言内容",
        },
       code:{
            required: "请输入验证码", 
        }
    },
    submitHandler:function(form){ 
       submitForm();
    }    
});

$(".textarea").bind('propertychange input', function () {
    var counter = $('.textarea').val().length;
    $(".number").text(counter);
});

});

function submitForm(){
		 var data =$('#commentForm').serialize();
         $.post(basePath+"user/leave/add",data,function(data) {
        	 	var code=data.code;
        		var msg=data.msg;
        		if (data.success) {
        			alert("非常感谢您的留言，我们会及时与您沟通，感谢对有贝口腔网支持");
        			location.reload();
        		} else {
        			alert(msg);
        			//reCode();
        		}
   	});
}

function reCode(){
	 $("#codeImg").attr("src",basePath+"common/vcode?r="+new Date());
} 